//package com.zucc.config;
//
//import com.railway.store.annotation.NoNeedLogin;
//import com.railway.store.constant.RailConstant;
//import com.railway.store.constant.RailwayCommonErrorCode;
//import com.railway.store.exception.RailwayException;
//import lombok.extern.slf4j.Slf4j;
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.annotation.Around;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.annotation.Pointcut;
//import org.aspectj.lang.reflect.MethodSignature;
//import org.springframework.core.annotation.Order;
//import org.springframework.web.context.request.RequestContextHolder;
//import org.springframework.web.context.request.ServletRequestAttributes;
//
//import java.lang.reflect.Method;
//
//@Order(11)
//@Aspect
//@Slf4j
//public class RailwayFacadeServerCheckLoginInterceptor {
//
//    @Pointcut(value = "execution(public * com.railway..*.controller..*.*(..))")
//    public void checkLoginPoint() {
//    }
//
//    @Around("checkLoginPoint()")
//    public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
//        Method targetMethod = ((MethodSignature) (pjp.getSignature())).getMethod();
//        NoNeedLogin noNeedLogin = targetMethod.getDeclaringClass().getAnnotation(NoNeedLogin.class);
//        if (noNeedLogin != null) {
//            return pjp.proceed();
//        }
//        noNeedLogin = targetMethod.getAnnotation(NoNeedLogin.class);
//        if (noNeedLogin != null) {
//            return pjp.proceed();
//        }
//        // 只要head中有token，就认为登录过了
//        Object obj = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest().getHeader(RailConstant.CURRENT_TOKEN);
//        if (obj == null) {
//            log.info("登录信息为空，请check有没有在Filter中Add名为current_info的Attribute");
//            throw new RailwayException(RailwayCommonErrorCode.NOT_LOGIN.getCode(), RailwayCommonErrorCode.NOT_LOGIN.getMsg());
//        }
//        return pjp.proceed();
//    }
//}
